package com.example.film.controller;

import com.example.film.entity.CinemaSell;
import com.example.film.service.CinemaSellService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.sql.Date;
import java.util.List;

@Api(tags = "影院每日票房信息管理接口")
@CrossOrigin
@RestController
@RequestMapping("cinema/v1")
public class CinemaSellController {

    @Autowired
    private CinemaSellService cinemaSellService;

    @ApiOperation("影院每日票房信息")
    @GetMapping("/sell")
    public List<CinemaSell> getCinemaSell(){
        return cinemaSellService.findCinemaSell();
    }

    @ApiOperation("分页查询影院每日票房信息")
    @GetMapping("/sellInfo")
    public List<CinemaSell> getCinemaSellInfo(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize){
        return cinemaSellService.findCinemaSellInfo(pageNum,pageSize);
    }

    @ApiOperation("根据日期分页显示影院当日票房信息")
    @GetMapping("/date")
    public List<CinemaSell> getCinemaSellByDate(@RequestParam Date currentDate, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize){
        return cinemaSellService.findCinemaSellByDate(currentDate, pageNum, pageSize);
    }

    @ApiOperation("根据省市分页显示影院当日票房信息")
    @GetMapping("/province")
    public List<CinemaSell> getCinemaSellByProvince(@RequestParam(defaultValue = "北京市") String province, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize){
        return cinemaSellService.findCinemaSellByProvince(province, pageNum, pageSize);
    }

    @ApiOperation("根据日期查询不同省市每日票房信息")
    @GetMapping("/dateSell/{date}")
    public List<CinemaSell> getDaySumInfo(@PathVariable Date date){
        return cinemaSellService.findDaySumInfo(date);
    }
}
